import request from '@/utils/request'
import type { ApiResponse,MenuDTO,RouteMenu } from './types'

// 获取菜单树
export function getMenuTree() {
  return request.get<ApiResponse<RouteMenu[]>>('/menu/tree')
}

// 获取所有菜单（不分页）
export function getAllMenus() {
  return request.get<ApiResponse<RouteMenu[]>>('/menu/list')
}

// 添加菜单
export function addMenu(data: MenuDTO) {
  return request.post<ApiResponse>('/menu', data)
}

// 更新菜单
export function updateMenu(data: MenuDTO) {
  return request.put<ApiResponse>(`/menu/${data.id}`, data)
}

// 删除菜单
export function deleteMenu(id: number) {
  return request.delete<ApiResponse>(`/menu/${id}`)
}

// 获取菜单详情
export function getMenuDetail(id: number) {
  return request.get<ApiResponse<RouteMenu>>(`/menu/${id}`)
} 